package com.heliang.ui.info;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.appxiehui2.R;
import com.heliang.dataaccess.bean.MailListBean;
import com.heliang.util.ImageLoaderUtil;

public class AliveMemberAdapter extends BaseAdapter {
    private Context context;

    private List<MailListBean> members;

    public AliveMemberAdapter(Context context, List<MailListBean> datas) {
        this.context = context;
        this.members = datas;
    }

    public int getCount() {
        if (members != null && members.size() > 0) {
            return members.size();
        }
        return 0;
    }

    public Object getItem(int arg0) {
        return arg0;
    }

    public long getItemId(int arg0) {
        return arg0;
    }

    public View getView(int position, View contentView, ViewGroup pareId) {
        View rowView = contentView;
        if (rowView == null) {
            LayoutInflater inflater = LayoutInflater.from(context);
            rowView = inflater.inflate(R.layout.alive_member, null);
        }

        MailListBean member = members.get(position);
        TextView memberName = (TextView) rowView.findViewById(R.id.member_name);
        memberName.setText(member.getUsername());

        TextView memberDegree = (TextView) rowView.findViewById(R.id.member_degree);
        memberDegree.setText(member.getPost());

        ImageView imageView = (ImageView) rowView.findViewById(R.id.head_icon);
        ImageLoaderUtil.instance.setImageDrawable(member.getImgpath(), member.getImgurl(), imageView, true);
        rowView.setTag(R.id.head_icon, imageView);

        return rowView;
    }

}
